﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WhittleList.Bll;
using System.Data.Linq;
using WhittleList.Tests.Helpers;

namespace WhittleList.Tests.Mocks
{
    public class FakeSite : Moq.Mock<Site>
    {
        public FakeSite(int id, int createdById, string name, string url)
        {
            Setup(x => x.Id).Returns(id);
            //Setup(x => x.CreatedById).Returns(createdById);
            //SetupProperty(x => x.LastUpdatedById, createdById);
            SetupProperty(x => x.OwnerId, createdById);
            SetupProperty(x => x.Name, name);
            SetupProperty(x => x.Url, url);
        }

        public static List<FakeSite> GetList(int number)
        {
            var tmp = new List<FakeSite>();
            while(tmp.Count < number)
            {
                int i = tmp.Count + 1;
                tmp.Add(new FakeSite(i, i, string.Format("Site Name {0}", i), string.Format("SiteUrl{0}", i)));
            }
            return tmp;
        }

        internal void SetProjects(List<FakeProject> projects)
        {
            var tmp = new EntitySet<Project>();
            tmp.Assign(projects.Convert());
            Setup(x => x.Projects).Returns(tmp);

            projects.ForEach(x => x.SetSite(this));
        }
    }

    /*public static class FakeSiteHelpers
    {
        public static IQueryable<Site> Convert(this IQueryable<FakeSite> data)
        {
            return data.Select(x => x.Object);
        }
    }*/
}
